<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('单据查询列表')" />
	<th:block th:include="include :: list-css" />
    <style>
        .layui-tab-title{border-color: #ccc !important;}
        .layui-this{color: rgb(0, 135, 250) !important;background: none !important;}
        .layui-tab-brief > .layui-tab-title .layui-this:after, .layui-tab-brief > .layui-tab-more li.layui-this:after{border-color:  rgb(0, 135, 250) !important;}
        .mid-content {overflow: auto;}

        tr img{width: 30px !important;height: 30px !important;margin: 0 2px;}
        .ishide{display: none;}
        .bagimg{z-index: 999;max-width:200px;border: 5px solid #23b971}
        .layui-table-view .layui-table .layui-table-cell{height: auto !important;}
        .layui-table-tips-main img{margin: 10px;width: 200px;}
    </style>
</head>
<body class="no-skin">
    <div class="ishide"><img class="bagimg" src=""/></div>
<script type="text/html" id="toolbar">
	<div class="layui-btn-container">
		<div class="layui-btn layui-btn-normal layui-table-tools" lay-event="addbtn">
			<i class="dhicon dh-lujing1089"></i> 新增
		</div>
        <!-- <div class="layui-btn layui-btn-normal layui-table-tools" lay-event="deleteBatch">
			<i class="dhicon dh-remove"></i> 删除
		</div> -->
        <!-- <div class="layui-btn layui-btn-normal layui-table-tools" lay-event="exportbtn">
			<i class="dhicon dh-zu4250_2_2"></i> 导出
		</div> -->
    </div>
</script>
<script type="text/html"  id="file2_imageUrl"> 
    {{# 
        var str=`<img src="${d.imageUrl}"/>`;
        return str;
    }}
</script>
<!-- 表格操作区 -->
<script type="text/html" id="barDh">
    <a class="layui-btn layui-btn-danger layui-btn-xs dhicon dh-edit" onclick="editbtn('{{d.guid}}','{{d.code}}')" shiro:hasPermission="storage:assemblymaintain:edit">&nbsp;修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs dhicon dh-remove"  onclick="remove('{{d.guid}}')">&nbsp;删除</a>  
</script>
<script th:inline="javascript">
    /*<![CDATA[*/
    var gridColumns = [[${gridColumns}]],
        business = [[${storage}]],
        buttonState = [[${buttonState}]],
        businessName = gridColumns.moduleAlias,
        passwordAuthentication = [[${passwordAuthentication}]],
        moduleTable = [[${moduleTable}]];
    /*]]>*/
    var prefix = "/business/indeximage";
	var tableUrl = prefix + "/list",
	exportUrl = prefix + "/export";
	delUrl = prefix+"/delete";
</script>
<th:block th:include="listinclude :: container" />
<th:block th:include="include :: footer" />
<th:block th:include="include :: tableBtn" />
<th:block th:include="listinclude :: list-templeat" />
<th:block th:include="include :: searchJS" />
<!-- <th:block th:include="include :: listJS" /> -->

<script type="text/javascript">
    var $,layer,laydate,form,table,wherestr={};
    layui.use(['table','laydate','form','layer','jquery','element'], function () {
        $ = layui.$, layer = layui.layer,laydate = layui.laydate , form = layui.form, table = layui.table, element = layui.element;

        $.tablelist.init({
		elem: '#dhtable'
		,modalName: "产品信息"
		,url: prefix + '/list'
		,updateUrl: prefix + "/edit?guid={id}"
		,initSort: {field: 'createTime',type: 'asc'}
		,totalRow: gridColumns.totalRow
		,cols: [gridColumns.gridBody]
		,toolbar: '#toolbar'
		,defaultToolbar: [{title:'列设置',layEvent: 'fieldSet',icon: 'layui-icon-set'}] //这里在右边显示
		,height:'full-65'
        ,parseData: function(res){ //res 即为原始返回的数据
			var objpage=sessionStorage.getItem(moduleTable+'checkdata')
			if(objpage){
				objpage=JSON.parse(objpage)
				res.data.map((v,i)=>{
					objpage.map((n,m)=>{
						 if(v.guid==n.guid){
							v.LAY_CHECKED=true
						 }
					})
				})
			}
		}
        ,done:function(){
            firstimg()//图片放大
        }
	});

        table.on('toolbar(ftable)', function(obj){
            switch(obj.event){
                case 'addbtn':
			        dialog('新增',prefix+ "/edit?guid=0",600,500,'addpost'); 
				    break;
            }
        })

        //新增修改弹出框
	    window.dialog=function (title,url,width,height,Method){
            $.modal.open(title,url,width,height,function(index){
                var inputForm = $(window.frames["layui-layer-iframe" + index].document).contents().find(".layui-form");
                var is_return = 0,
                    // postStr = [],
                    must_field={},
                    Str = inputForm.serializeFormToJson();

                $.each(gridColumns.dictionaryForPageFieldList,function (fk,fv) {
                    if(fv.fieldFrontRequired)
                        must_field[fv.fields] = fv.fieldName + " 不能为空";
                })
                $.each(must_field,function (k,v) {
                    if(!inputForm.find("#"+k).val()){
                        layer.msg(v);
                        is_return = 1;
                        inputForm.find("#"+k).css('border','1px solid red');
                        inputForm.find("#"+k).focus()
                        return false;
                    }
                })
                if(is_return)return false;
                var deldata = {'infoItems':JSON.stringify(Str)};
                $.operate.post('/business/indeximage/editpost',deldata,function(result){
                    allReload(result)
                });
            })
        }
        window.allReload= function(result){
            if(result.code==0){
                setTimeout(function(){
                    layer.closeAll();
                    table.reload('dhtable');
                }, 1000);
            }
        }

    })
    //弹出框修改
    function editbtn(guid){
    	dialog('修改',prefix+ "/edit?guid="+guid,600,500,'addpost');
    }
    //删除和批量操作
    function remove(guid){
    	if(guid){
    		$.operate.remove("该删除无法恢复，请确认？",prefix + "/delete/",{'infoItems':JSON.stringify([{'guid':guid}])},function(result){
			allReload(result)
		});
    	}else{
    		if(table.checkStatus('dhtable').data.length>0){
			$.operate.remove("是否彻底删除选中的"+table.checkStatus('dhtable').data.length+"条数据？",prefix + "/delete/",{'infoItems':JSON.stringify(table.checkStatus('dhtable').data, null, 2)},function(result){
				allReload(result)
			});
		}else{
    			layer.msg("无勾选数据！");
    		};
    	}
    }

</script>

</body>
</html>